package service.impl;

import dao.DBdao;
import dao.impl.DBdaoImpl;
import service.loginService;


import java.util.List;
import java.util.Map;

public class loginServiceImpl implements loginService {

    DBdao db=new DBdaoImpl();
    /**
     * 登录验证
     * @param username 用户名
     * @param password 密码
     * @return
     */
    @Override
    public int loginCheck(String username, String password) {

        Object[] param ={username};
        //查询用户名是否存在
        String sql1="SELECT username FROM user WHERE username = ?";

        String sql2="SELECT username,password FROM user WHERE username = ? AND password = ?";

        List<Map<String,Object>> list=db.select(sql1,param);

        if(list.isEmpty()){
            return 0;
        }
        return 1;
    }
}
